package com.yilee.idouban.util;

import java.util.Hashtable;

public class AnalyzeResponse {

	/*
	 * 分析用户授权后的response
	 */
	public static Hashtable<String, String> AnalyzeAuthorizeReponse(
			String response) {
		Hashtable<String, String> ht = new Hashtable<String, String>();
		if (response.contains("error")) { /* 拒绝授权 */
			ht.put("result", "0");
			ht.put("error", response.substring(response.indexOf("error=") + 6));
		} else if (response.contains("access_token")) {
			ht.put("result", "1");
			String access_token = response.substring(
					response.indexOf("access_token=")+13,
					response.indexOf("&expires_in"));
			ht.put("access_token", access_token);
		}
		return ht;
	}

}
